package model.inventory.item;

public class Item {
	private int itemID;
	private long quantity;
	
	public Item(int itemID, long quantity){
		this.itemID = itemID;
		this.quantity = quantity;
	}

	public int getID() {
		return itemID;
	}

	public long getQuantity() {
		return quantity;
	}

	public void add(long quantity) {
		this.quantity += quantity;
	}

	public Item remove(long quantity) {
		if(this.quantity == -1)
			return new Item(this.itemID, quantity);
		if(this.quantity <= quantity){
			long temp = this.quantity;
			this.quantity = 0;
			return new Item(this.itemID, temp);
		}
		this.quantity -= quantity;
		return new Item(this.itemID, quantity);
	}
	
	public boolean equals(Item i){
		if(this.itemID == i.itemID && this.quantity == i.quantity)
			return true;
		return false;
	}
	
	public int getBuildingID(){
		if(itemID >= 100){
			return itemID;
		}
		return -1;
	}

	public boolean isPlaceable() {
		if(this.itemID >= 100)
			return true;
		return false;
	}
}
